package pro.cherish.smartfile.common.enums.biz;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import pro.cherish.smartfile.common.enums.StatusEnum;
import pro.cherish.smartfile.module.resp.TransmissionStatusResp;

/**
 * @author 创建人：lys
 * @version 版本号：V1.0
 * <p>
 * ***************************修订记录************************************
 * 2020-12-03 lys 创建该类功能。
 * **********************************************************************
 * </p>
 * @ClassName 类名：ChunkStatusEnum
 * @Description 功能说明：
 * <p>
 *
 * </p>
 * **********************************************************************
 * @date 创建日期： 2020-12-03 lys
 */
@Getter
public enum ChunkStatusEnum implements StatusEnum {
    UP_FAIL("up_fail", "块上传失败"),
    UP_OK("up_ok", "块上传成功"),
    BLOCK_EXIST("block_exist", "块存在");

    private String code;
    private String msg;

    private TransmissionStatusResp transmissionStatusResp;

    ChunkStatusEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public TransmissionStatusResp getStatus() {
        return TransmissionStatusResp.builder().code(code).message(msg).build();
    }

    @Override
    public String getCode() {
        return this.code;
    }

    @Override
    public String getDesc() {
        return StrUtil.format("code={},msg={}", code, msg);
    }

    @Override
    public boolean eq(String val) {
        return StrUtil.equals(val, this.getValue());
    }

    @Override
    public String getValue() {
        return this.getValue();
    }
}
